package com.springboot.demo.linked;

/**
 * 双向链表测试
 *
 * @author supu
 * @date 2019-06-19 14:20
 **/
public class DoubleLinkedDemo {
    public static void main(String[] args) {
        DoubleNode node1 = new DoubleNode("one");
        DoubleNode node2 = new DoubleNode("two");
        DoubleNode node3 = new DoubleNode("three");

        DoubleLinkedList linkedList = new DoubleLinkedList();

        linkedList.insertLast(node1);
        linkedList.insertLast(node2);
        linkedList.insertLast(node3);
        linkedList.printDoubleLinkList();

        linkedList.removeNode(node2);
        linkedList.printDoubleLinkList();

        linkedList.insertFirst(new DoubleNode("zero"));
        linkedList.printDoubleLinkList();

        linkedList.removeTail();
        linkedList.printDoubleLinkList();

        linkedList.removeHead();
        linkedList.printDoubleLinkList();
    }
}
